<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 异常错误报错级别,
error_reporting(E_ERROR | E_PARSE );

// 应用公共文件
define('URL', "http://" . $_SERVER['HTTP_HOST'] . ":" . $_SERVER["SERVER_PORT"] . "/index.php");


////redis 配置
//function redis_conf()
//{
//    $options = [
//        'type' => 'redis',//指定类型
//
//        'password' => '1234567890',
//
//        'prefix' => 'sbn-',
//
//        'host' => '127.0.0.1',
//
//    ];
//    return Cache::init($options);//初始化
//}
//
//redis_conf();


/*
     * 根据二维数组某个字段的值查找数组
    */
function filter_by_value($array, $index, $value, $type)
{
    if (is_array($array) && count($array) > 0) {
        foreach (array_keys($array) as $key) {
            $temp[$key] = $array[$key][$index];
            if ($type == "<") {
                if ($temp[$key] < $value) {
                    $newarray[$key] = $array[$key];
                }
            } else {
                if ($type == "=") {
                    if ($temp[$key] <= $value) {
                        $newarray[$key] = $array[$key];
                    }
                } else {
                    if ($type == ">") {
                        if ($temp[$key] > $value) {
                            $newarray[$key] = $array[$key];
                        }
                    }
                }
            }
        }
    }
    return $newarray;
}
